﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AiXiu.Model;

namespace AiXiu.DAL
{
    public class LoginDAL
    {
        AiXiuDbContext dbContext = new AiXiuDbContext();
        /// <summary>
        /// 通过用户名获取信息
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <returns></returns>
        public TBLogins getUserbyName(string UserName) 
        {
            TBLogins login = dbContext.TBLogins.FirstOrDefault(t => t.UserName == UserName);
            return login;
        }
        /// <summary>
        /// 通过手机号获取信息
        /// </summary>
        /// <param name="Phone">手机号</param>
        /// <returns></returns>
        public TBLogins getUserbyPhone(string Phone)
        {
            return dbContext.TBLogins.FirstOrDefault(t => t.MobileNumber == Phone);
        }
        
        /// <summary>
        /// 通过Id查找用户的具体信息
        /// </summary>
        /// <param name="id">用户的Id</param>
        /// <returns></returns>
        public TBUsers get(int id) 
        {
            return dbContext.TBUsers.Find(id);
        }
    }
}
